package com.sinosoft.perfect.common.xmlService;

import java.io.File;
import java.util.List;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

public abstract class XmlReaderDom4j {

	@SuppressWarnings("unchecked")
	public static List<Element> readerXMLFileByXpathReturnElements(File f,String xpath) throws DocumentException {
		SAXReader reader = new SAXReader();
		Document doc = reader.read(f);
		Element root = doc.getRootElement();
		return root.selectNodes(xpath );
	}
	
	/*public static void main(String args[]) throws DocumentException{
		File f = new File(SystemServiceInOracleImpl.XMLFILE);
		List<Element> list = XmlReaderDom4j.readerXMLFileByXpathReturnElements(f, "//tables/table/initData");
		for (Iterator<Element> iter = list.iterator(); iter.hasNext(); ) {
		 Element e = iter.next();
		 System.out.println(e.getText().replaceAll("'", "''"));
        }
	}*/
}
